home *** CD-ROM | disk | FTP | other *** search
- Path: acsu.buffalo.edu!rastrl
- From: rastrl@cs.buffalo.edu (Robert L Rast)
- Newsgroups: comp.infosystems.www.servers.unix,comp.lang.c
- Subject: Re: Opening a binary file.... (dealing with content-type & WWW)
- Date: 18 Apr 1996 08:08:36 GMT
- Organization: State University of New York at Buffalo/Computer Science
- Message-ID: <4l4ta4$7d1@azure.acsu.buffalo.edu>
- References: <317351DE.E7E@draper.com>
- NNTP-Posting-Host: gagarin.cs.buffalo.edu
- NNTP-Posting-User: rastrl
-
- In article <317351DE.E7E@draper.com>,
- Brandon Shalton <bshalton@draper.com> wrote:
- >Hello,
- >
- >I am trying to establish content-types (mime) based upon the header
- >of the file, rather than relying on the file extension. I have
- >instances where file extensions overlap...ex. .doc (microsoft word),
- >.doc (ascii text document).
- >
- >This is my first cut...
-
- > fd2=open(entries[0].val,O_RDONLY);
- > for(;;)
- > {
- > if( read(fd2, tbuf, 1) <=0 ) exit(1);
- > printf("%s", tbuf);
- > }
- >
- >
-
- Just taking a guess here, but use write instead of printf. You can get
- the number of bytes from the return from 'read'.
-
- The binary characters (null, eof, etc.) are being interpreted by printf.
-
-
- R.L.Rast ;'./
-
- "Putting out fires with gasoline."
- __ (.x.) __
- --rastrl@acsu.buffalo.edu--(,,^\--\-/--/^,,)--www.acsu.buffalo.edu/~rastrl--
-
-
-
-